package designMode.buildMode.factoryMethod.normalFactory;

import designMode.buildMode.factoryMethod.normalFactory.impl.MailSender;
import designMode.buildMode.factoryMethod.normalFactory.impl.SmsSender;

/**
 * Created by Administrator on 2018/4/10.
 */
public class SenderFactory {

    public Sender produce(String type) {
        if ("mail".equals(type)) {
            return new MailSender();
        } else if ("sms".equals(type)) {
            return new SmsSender();
        } else {
            System.out.println("请输入正确的类型!");
            return null;
        }
    }

    public static void main(String[] args) {
        SenderFactory factory = new SenderFactory();

        Sender sender = factory.produce("sms");
        sender.send();

        factory.produce("mail").send();
    }
}
